package com.xiaoy.core.base.dictionary.service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.springframework.stereotype.Service;

import com.xiaoy.util.json.JSONUtils;
import com.xiaoy.util.store.io.ReadFileUtil;
/**
 * 读取配置文件中的字典信息
 * @author chentianyi
 *
 */
@Service("dictionaryFileService")
public class DictionaryFileService {

	private static List<Map<String,String>> store = new ArrayList<Map<String,String>>();
	
	
	private DictionaryFileService () {
//		ReadFileUtil.readProperties("/dictionary");
		init();
	}
	
	private void init () {
		
		Map<String,String>map = ReadFileUtil.readDirProperties("dictionary");
		Map<String,String>m  = null;
		for (Entry<String, String> entry:map.entrySet()) {
			String value = entry.getValue();
//			vs.put(entry.getKey(), Arrays.asList(value.split(",")));
			System.out.println(entry.getKey()+"-->"+entry.getValue());
			store = JSONUtils.fromJson(value,List.class);
			
//			m = new HashMap<String, String>();
//			store.add(m);
		}
		System.out.println("-----------------------------------------------------");
		for (Map<String,String>mm:store) {
			for (Entry<String, String> e:mm.entrySet()) {
				System.out.println(e.getKey()+"-->"+e.getValue());
			}
		}
		
	}
	
	
}
